<layout name="page" />
<block name="content">
	{:widget('page_header/simple',array('name'=>'修改任务'))}
	<div class="row frame">
		<form method='post' id="form_data" name="form_data" enctype="multipart/form-data"   >
			<input type="hidden" id="id" name="id" value="{$vo.id}">
			<input type="hidden" id="ajax" name="ajax" value="0">
			<input type="hidden" id="executor" name="executor" value="{$vo.executor}">
			<input type="hidden" id="assign_user" name="assign_user" value="{$vo.assign_user}">
			<input type="hidden" id="opmode" name="opmode" value="edit">

			<div class="box">
				<label class="input-label" for="name">标题*：</label>
				<input class="input" type="text" id="name" name="name" check='required' info='请输入文件名' value="{$vo.name}">
			</div>
			<div class="box">
				<label class="input-label" for="name">指派给：</label>
				<div id="executor_list" class="multi-select-box">
					<span class="data-list">{:show_contact($vo['executor'],true)}</span>
					<input class="letter" type="text" >
					<label></label>
					<div class="search hidden">
						<ul></ul>
					</div>
				</div>
				<a class="add-on" onclick="select_executor();"><i class="fa fa-user"></i></a>
			</div>
			<div class="box">
				<label class="input-label" for="expected_time">期望完成时间：</label>
				<input class="input input-date-time w13" type="text" id="expected_time" name="expected_time" readonly="readonly" value="{:substr($vo['expected_time'],0,16)}">
			</div>
			<div class="box">
				<label class="input-label" for="content">任务描述：</label>
				<textarea class="editor" id="content" name="content" style="width:100%;height:300px;" check="required" info="请输入内容">{$vo.content}</textarea>
			</div>

			<div class="box">
				<label class="input-label" for="name">附件：</label>
				<div class="input-block">
					{:widget('file_upload/add')}
				</div>
			</div>
			<div class="box">
				<label class="input-label"></label>
				<a class="btn btn-normal" onclick="save();">保存</a>
				<a class="btn btn-return" onclick="go_return_url();">取消</a>
			</div>
		</form>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		layui.use(['global', 'editor','uploader'], function() {
			var fn = {
				save : function() {
					$("#executor").val("");
					$("#actor_wrap span.address_list span").each(function() {
						$("#executor").val($("#executor").val() + $(this).find("b").text() + '|' + $(this).attr("data") + ";");
					});
					$html = $("#executor").val();
					var re = new RegExp("dept_", "g");
					var arr = $html.match(re);
					if (arr != null) {
						$dept_count = arr.length;
						$total_count = $html.split(';').length - 1;
						if ($dept_count != $total_count) {
							layer.msg('部门和人员不能同时选择');
							return false;
						}
					}
					send_form('form_data', '{:url("save")}', '', function(ret) {
						if (ret.status == 1) {
							parent.layer.msg(ret.info);
							parent.layer.close(index);
							parent.location.reload(true);
						} else {
							parent.layer.msg(ret.info);
							return false;
						};
					});
				},
				select_executor : function() {
					winopen("{:url('select_executor')}", 560, 470);
				}
			};
			win_exp(fn);
		});

	</script>
</block>